import createAxios from "/@/utils/axios"
import { useAdminInfo } from "/@/stores/adminInfo"

export const url = "/system/"

export function index() {
	return createAxios({
		url: "/admin_api/system/index",
		method: "get"
	})
}

export function login(method: "get" | "post", params: object = {}) {
	return createAxios({
		url: "/admin_api/system/login",
		data: params,
		method: method
	})
}

//获取登录用户头像
export function GetAvatar(method: "get" | "post", params: object = {}) {
	return createAxios({
		url: url + "get_avatar",
		data: params,
		method: method
	})
}

export function logout() {
	const adminInfo = useAdminInfo()
	return createAxios({
		url: url + "logout",
		method: "POST",
		data: {
			refreshToken: adminInfo.getToken("refresh")
		}
	})
}
